import server from '../utils/request.js'

// 管理员登录
export const login = (data) => {
  return server({
    url: '/api/login',
    method: 'post',
    data,
  })
}
// 获取所有用户信息
export const getUserList = (params) => {
  return server({
    url: '/api/getUserList',
    method: 'get',
    params,
  })
}
// 根据emali搜索用户
export const getUserByEmail = (params) => {
  return server({
    url: '/api/getUserByEmail',
    method: 'get',
    params,
  })
}
// 根据id更新状态
export const updateUserStatus = (data) => {
  return server({
    url: '/api/updateUserStatus',
    method: 'post',
    data,
  })
}
// 添加用户
export const addUser = (data) => {
  return server({
    url: '/api/addUser',
    method: 'post',
    data,
  })
}
// 根据id删除用户
export const deleteUser = (data) => {
  return server({
    url: '/api/deleteUser',
    method: 'post',
    data,
  })
}
// 根据id获取用户信息
export const getUserById = (params) => {
  return server({
    url: '/api/getuserbyid',
    method: 'get',
    params,
  })
}
// 根据id更新用户信息
export const updateUser = (data) => {
  return server({
    url: '/api/updateuser',
    method: 'post',
    data,
  })
}
// 根据id更新用户信息
export const getbanner = (data) => {
  return server({
    url: '/getbanner',
    method: 'get',
    data,
  })
}
// 根据email判断用户是否存在
export const isExist = (params) => {
  return server({
    url: '/checkemail',
    method: 'get',
    params,
  })
}
// 根据类型和id删除轮播图
export const deleteBanner = (data) => {
  return server({
    url: '/api/deleteimg',
    method: 'post',
    data,
  })
}
// 获取商品分类 不需参数
export const getCategory = () => {
  return server({
    url: '/getgoodscategory',
    method: 'get',
  })
}
//根据bid获取商品
export const getgoodsbybid = (params) => {
  return server({
    url: '/getgoodsbybid',
    method: 'get',
    params,
  })
}
//根据gid获取商品 分类的 gid 品牌
export const getgoodsbygid = (params) => {
  return server({
    url: '/getgoodsbygid',
    method: 'get',
    params,
  })
}
//删除商品 根据id
export const deleteGoods = (data) => {
  return server({
    url: '/api/deleteGoods',
    method: 'post',
    data,
  })
}

//添加轮播图
export const addBanner = (data) => {
  return server({
    url: '/api/addCarousel',
    method: 'post',
    data,
  })
}
//添加商品
export const addGoods = (data) => {
  return server({
    url: '/api/addGoods',
    method: 'post',
    data,
  })
}
// 获取所有订单
export const getOrderList = (params) => {
  return server({
    url: '/api/getAllOrder',
    method: 'get',
    params,
  })
}
// 根据邮箱名字查询订单
export const getOrderByEmail = (params) => {
  return server({
    url: '/api/getOrderByEmail',
    method: 'get',
    params,
  })
}
// 根据id更新订单状态
export const updateOrderStatus = (data) => {
  return server({
    url: '/api/updateOrderStatus',
    method: 'post',
    data,
  })
}
